<template>
  <div class="sign-in-subscribe-income">
    <c-title text="管理奖记录"></c-title>
    <van-tabs v-model="active" @change="change" sticky>
      <van-tab title="全部"></van-tab>
      <van-tab title="未结算"></van-tab>
      <van-tab title="已结算"></van-tab>
    </van-tabs>
    <main class="main" v-if="list && list.length!==0">
      <div v-for="(item,i) in list" :key="i" class="box">
        <div class="left">
          <p class="c-2b2b2b text-left m-b-30 f-13">{{item.activity_name}}</p>
          <p class="c-696969 f-11">{{item.created_at}}</p>
        </div>
        <div class="right">
          <p class="c-f14e4e m-b-30 f-13">{{item.dividend_amount}}</p>
          <p class="c-666 f-11">{{item.status_name}}</p>
        </div>
      </div>
    </main>
    <van-empty v-else description="暂无记录"></van-empty>
  </div>
</template>

<script>
import { scrollMixin } from "../../../utils/mixin";
export default {
  mixins: [scrollMixin],
  data() {
    return {
      active: 0,
      isLoadMore: true,
      current_page: 1,
      last_page: 1,
      list: []
    };
  },

  activated() {
    this.active = 0;
    this.isLoadMore = true;
    this.page = 1;
    this.total_page = 0;
    this.getData();
  },
  methods: {
    async change() {
      let json = {
        reward_type: "manage_award"
      };
      if (this.active == 1) {
        json.status = 0;
      } else if (this.active == 2) {
        json.status = 1;
      }
      let { result, msg, data } = await $http.get("plugin.sign-buy.frontend.reward-detail.record-page", json,".");
      if (result == 0) return this.$toast(msg);
      this.list = data.data || [];
      this.current_page = data.current_page;
      this.last_page = data.last_page;
    },
    async getData() {
      let { result, msg, data } = await $http.get("plugin.sign-buy.frontend.reward-detail.record-page", { reward_type: "manage_award" });
      if (result == 0) return this.$toast(msg);
      this.list = data.data || [];
      this.current_page = data.current_page;
      this.last_page = data.last_page;
    },
    async getMoreData() {
      if (this.current_page >= this.last_page) {
        return;
      }
      this.isLoadMore = false;
      let page = this.page + 1;
      let json = {
        reward_type: "manage_award",
        page
      };
      if (this.active == 1) {
        json.status = 0;
      } else if (this.active == 2) {
        json.status = 1;
      }
      let { result, msg, data } = await $http.get("plugin.sign-buy.frontend.reward-detail.record-page", json);
      this.isLoadMore = true;
      if (result == 0) return this.$toast(msg);
      this.list = this.list.concat(data.data);
      this.current_page = data.current_page;
      this.last_page = data.last_page;
    }
  }
};
</script>

<style scoped lang="scss">
.sign-in-subscribe-income {
  .main {
    padding: 0.625rem;
  }

  .text-left {
    text-align: left;
  }

  .f-13 {
    font-size: 0.8125rem;
  }

  .m-b-30 {
    margin-bottom: 0.9rem;
  }

  .f-11 {
    font-size: 0.6875rem;
  }

  .box {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.625rem;
    padding: 0.9375rem 0.6875rem;
    background: #fff;
    border-radius: 0.3125rem;
  }

  .c-696969 {
    color: #696969;
  }

  .c-666 {
    color: #666;
  }

  .c-2b2b2b {
    color: #2b2b2b;
  }

  .c-f14e4e {
    color: #f14e4e;
  }
}
</style>
